package it.yuzuojian.com.service.impl;

import it.yuzuojian.com.dao.SongMapper;
import it.yuzuojian.com.domain.Song;
import it.yuzuojian.com.service.SongService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SongServiceImpl implements SongService {
    @Autowired
    private SongMapper songMapper;
    @Override
    public Boolean insert(Song song) {
        int i=0;
        try {
            i=songMapper.insert(song);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i>0;
    }

    @Override
    public Boolean update(Song song) {
        return songMapper.update(song)>0;
    }

    @Override
    public Boolean delete(Integer[] ids) {
        Boolean flag=true;
        for (Integer id : ids) {
            System.out.println(id);
            flag=songMapper.delete(id)>0;
        }
        return flag;
    }

    @Override
    public Song selectById(Integer id) {
        return songMapper.selectById(id);
    }

    @Override
    public List<Song> selectAll() {
        return songMapper.selectAll();
    }

    @Override
    public List<Song> selectByName(String name) {
        name="%"+name+"%";
        return songMapper.selectByName(name);
    }

    @Override
    public Song selectOneByName(String name) {
        return songMapper.selectOneByName(name);
    }

    @Override
    public List<Song> selectBySingerId(Integer singerId) {
        return songMapper.selectBySingerId(singerId);
    }


}
